use proto_bytes::ProtoEncode2;

use super::driver::hx711::{read1, read2};

const VERSION: u16 = 0x03;

pub fn collect() -> impl ProtoEncode2 + Copy {
    let r1 = read1();
    let r2 = read2();

    let flag1 = r1.is_err();
    let flag2 = r2.is_err();

    let v1 = r1.unwrap_or(0);
    let v2 = r2.unwrap_or(0);
    let flag = (flag1 as u8) | ((flag2 as u8) << 1);

    (VERSION, (v1, (v2, flag)))
}
